package com.lakers.notice.springboot.netty.processor;

import com.lakers.notice.springboot.netty.CmdType;
import com.lakers.notice.springboot.util.SpringContextHolder;

/**
 * 功能描述: ProcessorFactory
 *
 * @author liqin(zxl)
 * @date 2024/5/3
 */
public class ProcessorFactory {

    public static  AbstractMessageProcessor createProcessor(CmdType cmd) {
        AbstractMessageProcessor processor = null;
        switch (cmd) {
            case LOGIN:
                processor = SpringContextHolder.getApplicationContext().getBean(LoginProcessor.class);
                break;
            case HEART_BEAT:
                processor = SpringContextHolder.getApplicationContext().getBean(HeartbeatProcessor.class);
                break;
            case MESSAGE:
                processor = SpringContextHolder.getApplicationContext().getBean(MessageProcessor.class);
                break;
            default:
                break;
        }
        return processor;
    }
}
